// 信息弹窗组件
<template>
  <div class="tag-container">
    <el-form
      class="form"
      ref="operaForm"
      :model="operaForm"
      label-width="100px"
    >
      <template v-if="operaForm.length > 0">
        <el-form-item
          v-if="item.prop.indexOf('target') === -1"
          v-for="item in operaForm"
          :key="item.id"
          :prop="item.prop"
          :label="item.label"
          :placeholder="item.placeholder"
        >
          <el-input v-if="item.prop === 'first_current'" v-model="form[item.prop][item.what]" :disabled="true" />
          <!-- <el-input v-if="item.prop === 'weight' || item.prop === 'granularity_size'" v-model="computWeight" :disabled="true" /> -->
          <!-- <el-input v-if="item.prop === 'granularity_size'" v-model="computSize" :disabled="true" /> -->
          <el-input v-else v-model="form[item.prop]" :disabled="true" />
        </el-form-item>
      </template>
    </el-form>
  </div>
</template>

<script>
import { productInfoOperaList as operaForm } from '@/assets/staticData/operaList.js'
export default {
  name: '',
  components: {},
  props: ['form', 'kind'],
  data () {
    return {
      // kind: '',
      operaForm: [] // 太智障了之前忘了定义这个 一直出错
    }
  },
  computed: {
    // computWeight () {
    //   let arr = this.form.granularity
    //   for (let i = 0; i < arr.length; i++) {
    //     if (arr[i].weight === 'weight') {
    //       return arr[i].weight
    //     } else {
    //       return arr[i].granularity_size
    //     }
    //   }
    // }
  },
  watch: {},
  created () {
    // console.log('this.operaForm', this.operaForm)
    // console.log('scope.row', this.form)
    // console.log('this.kind', this.kind)
    if (this.kind !== 'productInfo') {
      this.getOperaForm()
    } else {
      this.operaForm = operaForm
    }
    // console.log('infoTag', this.operaForm)
  },
  mounted () {
    // this.kind = kind
    // console.log(this.form, 'scope.row')
  },
  methods: {
    getOperaForm () {
      this.$axios.get(`http://127.0.0.1:7002/${this.kind}OperaForm`).then(res => {
        this.operaForm = res.data.tableData
      })
    }
  }
}
</script>

<style scoped lang="">
.form {
  width: 1000px;
}
/* 表单横向排列 */
.el-form-item {
  /* width: 100px; */
  display: inline-block !important;
}
/* 输入框样式 */
/deep/.el-input.is-disabled .el-input__inner {
  background-color: #f5f7fa;
  border-color: #e4e7ed;
  color: rgba(14, 22, 41, 0.8);
  /* cursor: not-allowed; */
  cursor: default;
}
</style>
